/**
 * 
 */
package com.dp.behav.chainofresp;

/**
 * This is to describe chain of responsibility pattern
 * 
 * The Chain of Responsibility design pattern allows an object to send a command
 * without knowing what object will receive and handle it. The request is sent
 * from one object to another making them parts of a chain and each object in
 * this chain can handle the command, pass it on or do both.It avoids attaching
 * the sender of a request to its receiver, giving this way other objects the
 * possibility of handling the request too.
 * 
 * @author Sunaina.Sharma
 * 
 */
public class ChainOfResponsibility {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// Setup Chain of Responsibility
		Handler h1 = new ConcreteHandlerOne();
		Handler h2 = new ConcreteHandlerTwo();
		Handler h3 = new ConcreteHandlerThree();
		h1.setSuccessor(h2);
		h2.setSuccessor(h3);

		// Send requests to the chain
		h1.handleRequest(new Request("Negative Value ", -1));
		h1.handleRequest(new Request("Negative Value ", 0));
		h1.handleRequest(new Request("Negative Value ", 1));
	}
}
